package com.lerarneurekacheckinvoke.eurekacheckinvoke.controller;

import com.lerarneurekacheckinvoke.eurekacheckinvoke.common.Result;
import com.lerarneurekacheckinvoke.eurekacheckinvoke.dao.doLogin;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class doLogincontroller {
    @Autowired
    doLogin doLogin;
    @ApiOperation(value = "登录接口",httpMethod = "POST")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "account", required = true, type = "string"),
            @ApiImplicitParam(name = "password", required = true, type = "string")
    })
    @PostMapping("/login")
    public Result doLogin(@RequestParam("account")String account, @RequestParam("password")String password){
        return doLogin.doLogin(account,password);
    }
    @ApiOperation(value = "注销接口",httpMethod = "Get")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="Token",required = true,type = "String")
    })
    @GetMapping("/logout")
    public Result logout(@RequestHeader(value = "Token")String token){
        return doLogin.logout(token);
    }
}
